#include <iostream>
#include <vector>
using namespace std;


struct ListNode {
      int val;
      struct ListNode *next;
      ListNode(int x) :
            val(x), next(NULL) {
      }
};

class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        ListNode* tmp;
        vector<int> result;
        while(head != NULL) {
            result.push_back(head->val);
            head = head->next;
        }
        int i = 0, j = result.size() - 1;
        int t;
        for (; i < j; i++, j--) {
            t = result[i];
            result[i] = result[j];
            result[j] = t;
        }
        return result;
    }
};
int main()
{
    Solution so;
    // cout << "Find: " << so.Find(1, array) << endl;;
    return 0;
}